<?php
include_once './' . drupal_get_path('theme', 'solveto') . '/inc/front/html.preprocess.inc';
include_once './' . drupal_get_path('theme', 'solveto') . '/inc/front/page.preprocess.inc';
include_once './' . drupal_get_path('theme', 'solveto') . '/inc/front/node.preprocess.inc';
include_once './' . drupal_get_path('theme', 'solveto') . '/inc/front/view.preprocess.inc';
include_once './' . drupal_get_path('theme', 'solveto') . '/inc/front/comment.preprocess.inc';
include_once './' . drupal_get_path('theme', 'solveto') . '/inc/front/template.process.inc';
/**
 * Global $base_url
 */

function base_url() {
    global $base_url;
    return $base_url;
}
function solveto_form_alter(&$form, &$form_state, $form_id){
    if (stristr($form_id, "commerce_cart_add_to_cart_form")) {
        $form['submit']['#prefix'] = '<div class = "add_buttons">';
        $form['submit']['#suffix'] = '</div>';
    } elseif(stristr($form_id, "form_commerce_cart_form")) {

    } elseif(stristr($form_id, "webform_client_form")) {
        $form['actions']['submit']['#prefix'] = '<div class="col-md-12">';
        $form['actions']['submit']['#suffix'] = '</div>';
    } elseif (stristr($form_id, "search_block_form")) {
        $form['search_block_form']['#attributes']['class'][] = 'search';
        $form['search_block_form']['#attributes']['placeholder'] = t('Search..');
        $form['#attributes']['class'][] = 'searh-holder';

        $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/img/search-icon-top.png');
        $form['actions']['submit']['#attributes'] = array(
            'class' => array('search-submit'),
        );
        $form['actions']['submit']['#value'] = t('');
    } elseif (stristr($form_id, "simplenews_block_form")) {
        $form['mail']['#attributes']['placeholder'] = t('Your Email Address');
    }

    else {
        $form['actions']['submit']['#prefix'] = '<div class = "save">';
        $form['actions']['submit']['#suffix'] = '</div>';
    }
}
function solveto_form_element($variables) {
    $element = $variables['element'];
    // Disable radio button N/A
    if ($element['#type'] == 'radio' && $element['#return_value'] === '_none') {
        $variables['element']['#attributes']['disabled'] = TRUE;
    }
    drupal_add_css(".form-radios .form-disabled {display: none;}",'inline');
    return theme_form_element($variables);
}

/**
 * Returns HTML for a wrapper for a menu sub-tree.
 *
 * @param $variables
 *   An associative array containing:
 *   - tree: An HTML string containing the tree's items.
 *
 * @see template_preprocess_menu_tree()
 * @ingroup themeable
 */
function solveto_menu_tree($variables) {
    return '<ul class="menu themeple_megamenu sub-menu">' . $variables['tree'] . '</ul>';
}
function solveto_menu_tree__responsive($variables) {
    return '<ul class="menu">' . $variables['tree'] . '</ul>';
}
/**
 * Overrides theme_menu_link().
 */
function solveto_menu_link(array $variables) {
    $frontpage = variable_get('site_frontpage','node');
    $element = $variables['element'];
    $sub_menu = '';
    if ($element['#below']) {
        // Prevent dropdown functions from being added to management menu so it
        // does not affect the navbar module.
        if (($element['#original_link']['menu_name'] == 'management') && (module_exists('navbar'))) {
            $sub_menu = drupal_render($element['#below']);
        }
        else {
            // Add our own wrapper.
            unset($element['#below']['#theme_wrappers']);
            $sub_menu = '<ul class="sub-menu non_mega_menu">' . drupal_render($element['#below']) . '</ul>';
            $element['#attributes']['class'][] = 'hasSubMenu';
            if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
                $element['#attributes']['class'][] = 'current-menu-ancestor current_page_ancestor';
            }
            //$element['#title'] = '<span class="plus"><span>+</span></span>'.$element['#title'];
            $element['#localized_options']['html'] = TRUE;
        }
    }
    // On primary navigation menu, class 'active' is not set on active menu item.
    // @see https://drupal.org/node/1896674
    if (($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#localized_options']['language']))) {
        $element['#attributes']['class'][] = 'current-menu-item current_page_item';
    }

    //$element['#localized_options']['html'] = true;

    $output = l($element['#title'], $element['#href'], $element['#localized_options']);
    if((!empty($element['#original_link']['depth'])) && ($element['#original_link']['depth'] != 1) && $element['#below']) {
        $element['#attributes']['class'][] = 'node';
    }
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
/**
 * Update status messages
 */
function solveto_status_messages($variables) {
    $display = $variables['display'];
    $output = '';

    $status_heading = array(
        'status' => t('Status message'),
        'error' => t('Error message'),
        'warning' => t('Warning message'),
        'info' => t('Informative message'),
    );

    // Map Drupal message types to their corresponding Bootstrap classes.
    // @see http://twitter.github.com/bootstrap/components.html#alerts
    $status_class = array(
        'status' => 'success',
        'error' => 'error',
        'warning' => 'warning',
        // Not supported, but in theory a module could send any type of message.
        // @see drupal_set_message()
        // @see theme_status_messages()
        'info' => 'info',
    );

    foreach (drupal_get_messages($display) as $type => $messages) {
        $class = (isset($status_class[$type])) ? $status_class[$type] : '';
        $output .= "<div class=\"notification-box notification-box-$class\">\n";


        if (!empty($status_heading[$type])) {
            $output .= '<h4 class="element-invisible">' . $status_heading[$type] . "</h4>\n";
        }
        $output .= '<div class="row-fluid sc-col row-dynamic-el">';
        if($status_class[$type] == 'success') {
            $output .= '<div class="alert alert-success"><a class="close" data-dismiss="alert" href="#">&times;</a>';
        }
        if($status_class[$type] == 'error') {
            $output .= '<div class="alert alert-error"><a class="close" data-dismiss="alert" href="#">&times;</a>';
        }
        if($status_class[$type] == 'warning') {
            $output .= '<div class="alert alert-warning"><a class="close" data-dismiss="alert" href="#">&times;</a>';
        }
        if($status_class[$type] == 'info') {
            $output .= '<div class="alert alert-information"><a class="close" data-dismiss="alert" href="#">&times;</a>';
        }
        if (count($messages) > 1) {
            $output .= " \n";
            foreach ($messages as $message) {
                $output .= '  <strong>' . $message . "</strong>\n";
            }
            $output .= " \n";
        }
        else {
            $output .= $messages[0];
        }
        $output .= '</div></div></div>';
        $output .= "</div>\n";
    }
    return $output;
}
/**
 * @param $form
 * @param $form_state
 * @param $form_id
 */

/*function solveto_form_alter(&$form, &$form_state, $form_id) {
    if (strpos((string)($form_id),"webform_client_form") === false) {
        switch ($form_id) {
            case 'user_login':
                $form['#attributes']['class'][] = 'form';
                $form['name']['#attributes']['class'][] = 'contact-form';
                $form['name']['#prefix'] = '<div class="input-wrapper">';
                $form['name']['#suffix'] = '</div>';
                $form['pass']['#attributes']['class'][] = 'contact-form';
                $form['pass']['#prefix'] = '<div class="input-wrapper">';
                $form['pass']['#suffix'] = '</div>';
                $form['actions']['submit']['#value'] = t('Login');
                $form['actions']['submit']['#attributes']['class'][] = 'btn btn-default pull-left';
                $form['actions']['submit']['#prefix'] = '';
                $form['actions']['submit']['#suffix'] = '';
                break;
            case 'user_register_form':
                $form['#attributes']['class'][] = 'form';
                $form['account']['name']['#attributes']['class'][] = 'contact-form';
                $form['account']['name']['#prefix'] = '<div class="input-wrapper">';
                $form['account']['name']['#suffix'] = '</div>';
                $form['account']['mail']['#attributes']['class'][] = 'contact-form';
                $form['account']['mail']['#prefix'] = '<div class="input-wrapper">';
                $form['account']['mail']['#suffix'] = '</div>';
                $form['actions']['submit']['#value'] = t('Create new account');
                $form['actions']['submit']['#attributes']['class'][] = 'btn btn-default pull-left';
                $form['actions']['submit']['#prefix'] = '';
                $form['actions']['submit']['#suffix'] = '';
                break;
            case 'user_login_block':
                $form['#attributes']['class'][] = 'form';
                $form['name']['#attributes']['class'][] = 'contact-form';
                $form['name']['#prefix'] = '<div class="input-wrapper">';
                $form['name']['#suffix'] = '</div>';
                $form['pass']['#attributes']['class'][] = 'contact-form';
                $form['pass']['#prefix'] = '<div class="input-wrapper">';
                $form['pass']['#suffix'] = '</div>';
                $form['actions']['submit']['#value'] = t('Login');
                $form['actions']['submit']['#attributes']['class'][] = 'btn btn-default pull-left';
                $form['actions']['submit']['#prefix'] = '';
                $form['actions']['submit']['#suffix'] = '';
                break;
            case 'user_pass':
                $form['name']['#attributes']['class'][] = 'contact-form';
                $form['name']['#prefix'] = '<div class="input-wrapper">';
                $form['name']['#suffix'] = '</div>';
                $form['pass']['#attributes']['class'][] = 'contact-form';
                $form['pass']['#prefix'] = '';
                $form['pass']['#suffix'] = '';
                $form['actions']['submit']['#value'] = t('Request new password');
                $form['actions']['submit']['#attributes']['class'][] = 'btn btn-default pull-left';
                $form['actions']['submit']['#prefix'] = '';
                $form['actions']['submit']['#suffix'] = '';
                break;
            case 'search_block_form':
                $form['search_block_form']['#attributes']['class'][] = 'search';
                $form['search_block_form']['#attributes']['placeholder'] = t('Search..');
                $form['#attributes']['class'][] = 'searh-holder';

                $form['actions']['submit'] = array('#type' => 'image_button', '#src' => base_path() . path_to_theme() . '/img/search-icon-top.png');
                $form['actions']['submit']['#attributes'] = array(
                    'class' => array('search-submit'),
                );
                $form['actions']['submit']['#value'] = t('');
                break;
            case 'search_form':
                $form['basic']['submit']['#prefix'] = '<div class="form-submit"><div class="form-controls">';
                $form['basic']['submit']['#suffix'] = '</div></div>';
                $form['basic']['submit']['#attributes'] = array(
                    'class' => array('transition button'),
                );
                $form['advance']['#prefix'] = '<div class="row"><div class="container">';
                $form['advance']['#suffix'] = '</div></div>';
                $form['advance']['submit']['#prefix'] = '<div class="form-submit"><div class="form-controls">';
                $form['advance']['submit']['#suffix'] = '</div></div>';
                $form['advance']['submit']['#attributes'] = array(
                    'class' => array('transition button'),
                );
                break;
        }
    } else {
        /*foreach($form['submitted'] as $id => $group) {
            if(is_array($group)) {
                if($group['#type'] == 'fieldset') {
                    foreach($group as $key => $value) {
                        if(stristr($key,'#')) {

                        } else {
                            if($value['#type'] == 'textfield' || $value['#type'] == 'webform_email' || $value['#type'] == 'select') {
                                $form['submitted'][$id][$key]['#prefix'] = '<div class="col-md-6 form-margin">';
                                $form['submitted'][$id][$key]['#suffix'] = '</div>';
                            }
                            if($value['#type'] == 'radio') {
                                $form['submitted'][$id][$key]['#prefix'] = '<div class="col-md-4">';
                                $form['submitted'][$id][$key]['#suffix'] = '</div>';
                            }
                            if($value['#type'] == 'textarea') {
                                $form['submitted'][$id][$key]['#prefix'] = '<div class="col-md-12">';
                                $form['submitted'][$id][$key]['#suffix'] = '</div>';
                            }
                        }
                    }
                } else {
                    if($group['#type'] == 'textfield' || $group['#type'] == 'webform_email' || $group['#type'] == 'select') {
                        $form['submitted'][$id]['#prefix'] = '<div class="col-md-6 form-margin">';
                        $form['submitted'][$id]['#suffix'] = '</div>';
                    }
                    if($group['#type'] == 'radio') {
                        $form['submitted'][$id]['#prefix'] = '<div class="col-md-4">';
                        $form['submitted'][$id]['#suffix'] = '</div>';
                    }
                    if($group['#type'] == 'textarea') {
                        $form['submitted'][$id]['#prefix'] = '<div class="col-md-12">';
                        $form['submitted'][$id]['#suffix'] = '</div>';
                    }
                }

            }
        }
        $form['#prefix'] = '<div class="row">';
        $form['#suffix'] = '</div>';
        //$form['actions']['submit']['#value'] = 'Send';
        $form['actions']['submit']['#attributes']['class'][] = 'submit';
        $form['actions']['submit']['#prefix'] = '<div class="col-md-12">';
        $form['actions']['submit']['#suffix'] = '</div>';
    }


}*/
/**
 * Update breadcrumbs
 */
function solveto_breadcrumb($variables) {
    $breadcrumb = $variables['breadcrumb'];
    if (!empty($breadcrumb)) {

        if (!drupal_is_front_page() && !empty($breadcrumb)) {
            $node_title = filter_xss(menu_get_active_title(), array());
            $breadcrumb[] = $node_title;
        }
        if (count($breadcrumb) == 1) {
            $breadcrumb = array();
        }
        return strip_tags(theme('item_list', array('items' => $breadcrumb, 'attributes' => array('class' => array('page_parents pull-right breadcrumb-list')))), '<ul><li><a>');
    }
}
/**
 * @param $variables
 * @return string
 * Theme File
 */
function solveto_file($variables) {
    $element = $variables['element'];
    $element['#attributes']['type'] = 'file';
    element_set_attributes($element, array('id', 'name', 'size'));
    _form_set_class($element, array('form-file'));
    $element['#attributes']['class'][] = 'upload-file';
    return '<input' . drupal_attributes($element['#attributes']) . ' />';
}
/**
 * @param $variables
 * @return string
 * Theme textfield
 */
function solveto_textfield($variables) {
    $element = $variables['element'];
    $element['#attributes']['type'] = 'text';
    element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength'));
    _form_set_class($element, array('form-text'));

    $extra = '';
    if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) {
        drupal_add_library('system', 'drupal.autocomplete');
        $element['#attributes']['class'][] = 'form-autocomplete';

        $attributes = array();
        $attributes['type'] = 'hidden';
        $attributes['id'] = $element['#attributes']['id'] . '-autocomplete';
        $attributes['value'] = url($element['#autocomplete_path'], array('absolute' => TRUE));
        $attributes['disabled'] = 'disabled';
        $attributes['class'][] = 'autocomplete';
        $extra = '<input' . drupal_attributes($attributes) . ' />';
    }
    $element['#attributes']['class'][] = 'input-style';

    $output = '<input' . drupal_attributes($element['#attributes']) . ' />';

    return $output . $extra;
}

/**
 * @param $variables
 * @return string
 * Theme textarea
 */
function solveto_textarea($variables) {
    $element = $variables['element'];
    element_set_attributes($element, array('id', 'name', 'cols', 'rows'));
    _form_set_class($element, array('form-textarea'));

    $wrapper_attributes = array(
        'class' => array('form-textarea-wrapper'),
    );

    // Add resizable behavior.
    if (!empty($element['#resizable'])) {
        drupal_add_library('system', 'drupal.textarea');
        $wrapper_attributes['class'][] = 'resizable';
    }
    $element['#attributes']['class'] = 'input-style';
    $output = '<div' . drupal_attributes($wrapper_attributes) . '>';
    $output .= '<textarea' . drupal_attributes($element['#attributes']) . '>' . check_plain($element['#value']) . '</textarea>';
    $output .= '</div>';
    return $output;
}

/**
 * @param $variables
 * @return string
 * Theme form element label
 */
function solveto_form_element_label($variables) {
    $element = $variables['element'];
    // This is also used in the installer, pre-database setup.
    $t = get_t();

    // If title and required marker are both empty, output no label.
    if ((!isset($element['#title']) || $element['#title'] === '') && empty($element['#required'])) {
        return '';
    }

    // If the element is required, a required marker is appended to the label.
    $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';

    $title = filter_xss_admin($element['#title']);

    $attributes = array();
    // Style the label as class option to display inline with the element.
    if ($element['#title_display'] == 'after') {
        $attributes['class'] = 'option';
    }
    // Show label only to screen readers to avoid disruption in visual flows.
    elseif ($element['#title_display'] == 'invisible') {
        $attributes['class'] = 'element-invisible';
    }

    if (!empty($element['#id'])) {
        $attributes['for'] = $element['#id'];
    }

    // The leading whitespace helps visually separate fields from inline labels.
    return ' <label' . drupal_attributes($attributes) . '>' . $t('!title !required', array('!title' => $title, '!required' => $required)) . "</label>\n";
}

/**
 * @param $variables
 * @return string
 * Theme fieldset
 */
function solveto_fieldset($variables) {
    $element = $variables['element'];
    element_set_attributes($element, array('id'));
    _form_set_class($element, array('form-wrapper'));

    $output = '<fieldset' . drupal_attributes($element['#attributes']) . '>';
    if (!empty($element['#title'])) {
        // Always wrap fieldset legends in a SPAN for CSS positioning.
        $output .= '<legend><span class="fieldset-legend">' . $element['#title'] . '</span></legend>';
    }
    $output .= '<div class="fieldset-wrapper">';
    if (!empty($element['#description'])) {
        $output .= '<div class="fieldset-description">' . $element['#description'] . '</div>';
    }
    $output .= $element['#children'];
    if (isset($element['#value'])) {
        $output .= $element['#value'];
    }
    $output .= '</div>';
    $output .= "</fieldset>\n";
    return $output;
}
/**
 * @param $variables
 * @return string
 * Theme select
 */
function solveto_select($variables) {
    $element = $variables['element'];
    element_set_attributes($element, array('id', 'name', 'size'));
    _form_set_class($element, array('form-select'));

    return '<div class="customlist"><select' . drupal_attributes($element['#attributes']) . '>' . form_select_options($element) . '</select></div>';
}

/**
 * @param $variables
 * @return string
 * Theme radio
 */
function solveto_radio($variables) {
    $element = $variables['element'];
    $element['#attributes']['type'] = 'radio';
    element_set_attributes($element, array('id', 'name','#return_value' => 'value'));

    if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
        $element['#attributes']['checked'] = 'checked';
    }
    _form_set_class($element, array('form-radio'));
    $element['#attributes']['class'][] = 'styled';
    return '<input' . drupal_attributes($element['#attributes']) . ' />';
}

/**
 * template_preprocess_user_picture()
 */
function solveto_preprocess_user_picture(&$variables) {
    $variables['user_picture'] = '';
    if (variable_get('user_pictures', 0)) {
        $account = $variables['account'];
        if (!empty($account->picture)) {
            // @TODO: Ideally this function would only be passed file objects, but
            // since there's a lot of legacy code that JOINs the {users} table to
            // {node} or {comments} and passes the results into this function if we
            // a numeric value in the picture field we'll assume it's a file id
            // and load it for them. Once we've got user_load_multiple() and
            // comment_load_multiple() functions the user module will be able to load
            // the picture files in mass during the object's load process.
            if (is_numeric($account->picture)) {
                $account->picture = file_load($account->picture);
            }
            if (!empty($account->picture->uri)) {
                $filepath = $account->picture->uri;
            }
        }
        elseif (variable_get('user_picture_default', '')) {
            $filepath = variable_get('user_picture_default', '');
        }
        if (isset($filepath)) {
            $alt = t("@user's picture", array('@user' => format_username($account)));
            // If the image does not have a valid Drupal scheme (for eg. HTTP),
            // don't load image styles.
            if (module_exists('image') && file_valid_uri($filepath) && $style = variable_get('user_picture_style', '')) {
                $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'path' => $filepath, 'alt' => $alt, 'title' => $alt, 'attributes' => array('class' => array(''))));
            }
            else {
                $variables['user_picture'] = theme('image', array('path' => $filepath, 'alt' => $alt, 'title' => $alt));
            }
            if (!empty($account->uid) && user_access('access user profiles')) {
                $attributes = array(
                    'attributes' => array('title' => t('View user profile.')),
                    'html' => TRUE,
                );
                $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes);
            }
        }
    }

}

/**
 * Get frontpage url
 */
function front_page() {
    $front_page = variable_get('site_frontpage', 'node');
    return $front_page;
}

/**
 * @return string
 * Get Theme path
 */
function theme_path() {
    $theme_path = drupal_get_path('theme','mdst');
    return $theme_path;
}
function strposa($haystack, $needles=array(), $offset=0) {
    $chr = array();
    foreach($needles as $needle) {
        $res = strpos($haystack, $needle, $offset);
        if ($res !== false) $chr[$needle] = $res;
    }
    if(empty($chr)) return false;
    return min($chr);
}
/**
 * Convert a hexa decimal color code to its RGB equivalent
 *
 * @param string $hexStr (hexadecimal color value)
 * @param boolean $returnAsString (if set true, returns the value separated by the separator character. Otherwise returns associative array)
 * @param string $seperator (to separate RGB values. Applicable only if second parameter is true.)
 * @return array or string (depending on second parameter. Returns False if invalid hex color value)
 */
function hex2RGB($hexStr, $returnAsString = false, $seperator = ',') {
    $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); // Gets a proper hex string
    $rgbArray = array();
    if (strlen($hexStr) == 6) { //If a proper hex code, convert using bitwise operation. No overhead... faster
        $colorVal = hexdec($hexStr);
        $rgbArray['red'] = 0xFF & ($colorVal >> 0x10);
        $rgbArray['green'] = 0xFF & ($colorVal >> 0x8);
        $rgbArray['blue'] = 0xFF & $colorVal;
    } elseif (strlen($hexStr) == 3) { //if shorthand notation, need some string manipulations
        $rgbArray['red'] = hexdec(str_repeat(substr($hexStr, 0, 1), 2));
        $rgbArray['green'] = hexdec(str_repeat(substr($hexStr, 1, 1), 2));
        $rgbArray['blue'] = hexdec(str_repeat(substr($hexStr, 2, 1), 2));
    } else {
        return false; //Invalid hex color code
    }
    return $returnAsString ? implode($seperator, $rgbArray) : $rgbArray; // returns the rgb string or the associative array
}
// Function helper to convert background theme-settings to css
function _brt_background_settings_to_css ($name) {
    $output = '';
    if(!empty($name)) {
        $output .= 'background: ';
        $type = theme_get_setting($name.'_type') ? theme_get_setting($name.'_type') : 'color';
        if($type == 'color') {
            $color = theme_get_setting($name.'_colorpicker');
            $output .= $color;
        } else {
            $enable_parallax = theme_get_setting($name.'_image_enable_parallax');
            $extra = '';
            if($enable_parallax == 0) {
                $extra .= theme_get_setting($name.'_image_position').' '.theme_get_setting($name.'_image_repeat').' '.theme_get_setting($name.'_image_attachment');
            } else {
                $extra .= ' fixed ';

            }
            if(module_exists('media')) {
                $media_file = theme_get_setting($name.'_media_file');
                if(!empty($media_file)) {
                    $file = json_decode($media_file);
                    if($file) {
                        $output .= 'url('.$file->url.')'.' '.$extra;
                    }
                }
            } else {
                $form_file = theme_get_setting($name.'_form_file');
                if(!empty($form_file)) {
                    $file_url = file_create_url(file_stream_wrapper_uri_normalize("public://".$form_file));
                    if($file_url) {
                        $output .= 'url('.$file_url.')'.' '.$extra;
                    }
                }
            }
        }
    }
    return $output;
}
// Function transfer parallax settings to javascript
function _brt_parallax_settings($name) {
    $output = '';
    $outerHeight = true;
    if(theme_get_setting($name.'_img_pr_outerheight') == 0) {
        $outerHeight = false;
    }
    $xpos = theme_get_setting($name.'_img_pr_xpos') ? theme_get_setting($name.'_img_pr_xpos') : '50%';
    $speedFactor = theme_get_setting($name.'_img_pr_speed') ? theme_get_setting($name.'_img_pr_speed') : 0.1;

    $output .= '"'.$xpos.'",'.$speedFactor.','.$outerHeight.'';

    return $output;
}

// Function render css options for overlay
function _brt_overlay_settings_to_css($name) {
    $output = '';
    if(!empty($name)) {
        $output .= 'background: rgba(';
        $color = hex2RGB(theme_get_setting($name.'_overlay_colorpicker'));
        if(!empty($color)) {
            $output .= $color['red'].','.$color['green'].','.$color['blue'].',';
        }
        $overlay = theme_get_setting($name.'_overlay_opacity') ? theme_get_setting($name.'_overlay_opacity') : 80;
        $output .= $overlay;
        $output .= ')';
    }
    return $output;
}
